package com.tledu.zyf.servlet.user;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.tledu.zyf.util.AjaxObj;
import com.tledu.zyf.util.ObjectFactory;

@WebServlet("/user/verifyUsername")
public class UserVerifyUsername extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String username = request.getParameter("username");
		boolean flag = ObjectFactory.getUserService().verifyUsername(username);
		if (flag) {
			response.getWriter().println(new AjaxObj(0, "用户名已存在").toJSON());
		} else {
			response.getWriter().println(new AjaxObj(1, "用户名可以使用").toJSON());
		}
	}
}
